We chose Washington D.C. as our target region for our analysis. Specifically, we were interested in providing geospatial data for bike tourists. Therefore, we downloaded geojson files for the following:
â—‹ historic monuments
â—‹ bike lanes
â—‹ tree canopies (so that bikers can take rest after or in-between sightseeing).
We first installed essential packages to plot geospatial data.
install.packages("tidyverse", quiet = TRUE)
install.packages("sf", quiet = TRUE)
install.packages("spData", quiet = TRUE)
install.packages("ggthemes", quiet = TRUE)
install.packages("ggspatial", quiet = TRUE)
install.packages("Rcpp", quiet = TRUE)
After installing core packages, we must import relevant libraries to use the functions utilizable in our assignment.
library(tidyverse)
library(sf)
library(ggthemes)
library(ggspatial)
As we downloaded geospatial files in geoJSON files, we must read them.
bikelanes <- st_read("Bike Trails.geojson", quiet= TRUE)
landmarks <- st_read("Potential Landmarks.geojson", quiet= TRUE)
canopy <- st_read("Tree Canopy.geojson", quiet= TRUE)
As we want to specify the draw order to avoid one layer covering another, we leave ggplot function blank and specify the dataset in geom_sf function. Also, we considered removing the gray background and painted it with white. Last, we erased the longitude and latidue for cleaner look.
ggplot() +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
theme_void()
Oftentimes, the default basemap has the most tidy look.
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none") +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
labs(caption = "Map tiles and data by OpenStreetMap") +
theme_void()
Our team found that the Hotstyle seems pretty useless.
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "hotstyle") +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
labs(caption = "Map tiles and data by OpenStreetMap") +
theme_void()
HikeBike is useful in showing bikelanes along with those of adjacent cities.
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "hikebike") +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
labs(caption = "Map tiles and data by OpenStreetMap") +
theme_void()
This map has a newspaper look, providing more comfort to the eyes.
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "osmgrayscale") +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
labs(caption = "Map tiles and data by OpenStreetMap") +
theme_void()
Simpler version of Stamen basemap.
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "stamenbw") +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
labs(caption = "Map tiles by Stament Design and data by OpenStreetMap") +
theme_void()
A picturesque map.
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "stamenwatercolor") +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
labs(caption = "Map tiles by Stament Design and data by OpenStreetMap") +
theme_void()
This map is also useless, but at least it looks catchy like a cartoon.
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "cartodark") +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
labs(caption = "Map tiles and data by OpenStreetMap") +
theme_void()
A pleasant-looking map which has cooler tone than other maps.
ggplot() +
annotation_map_tile(zoomin = 0, progress = "none", type = "cartolight") +
geom_sf(data = canopy, aes(color = "Canopies")) +
geom_sf(data = landmarks, aes(fill = "Historic Landmarks"), color = NA) +
geom_sf(data = bikelanes, aes(color = "Bike Lanes")) +
scale_fill_manual(values = "darkgoldenrod1", name = "") +
scale_color_manual(values = c("darkred", "forestgreen"), name = "") +
labs(caption = "Map tiles and data by OpenStreetMap") +
theme_void()